/**
 * Mongo数据层用于数据库连接的类 继承自IConnection
 */
package MongoDAL;

import Control.CConfig;
import DALFactory.IConn;
import com.mongodb.DB;
import com.mongodb.Mongo;

/**
 *
 * @author kocio
 */
public class MongodbConn implements IConn {

    private CConfig config = CConfig.getConfig();
    private DB db;
    private Mongo m;
    private String MongoDB_URL;
    private int MongoDB_PORT;
    private String MongoDB_DB;

    /**
     *
     */
    public MongodbConn() {

    	/**    MongoDB_URL = config.getProperties().get("MongoDB_URL").toString();
        String s = config.getProperties().get("MongoDB_Port").toString();
        MongoDB_PORT = Integer.parseInt(s);
        MongoDB_DB = config.getProperties().get("MongoDB_DB").toString();
*/
        MongoDB_URL = "127.0.0.1";
        MongoDB_PORT = 27017;

        MongoDB_DB = "RH";


        try {
            m = new Mongo(MongoDB_URL, MongoDB_PORT);
            db = m.getDB(MongoDB_DB);
            this.db = db;
            m = null;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     *
     * @return
     */
    protected DB getDB() {
        return db;
    }
    public void CloseDB()
    {
    	m.close();
    	
    }
}
